package ru.mipt.sport.model.entity;

import java.io.Serializable;
import javax.persistence.*;
import ru.mipt.sport.model.interfaces.SportLevel;

/**
 *
 * @author danon
 */
@Entity
public class SportLevelEntity implements Serializable, SportLevel {
    private static final long serialVersionUID = 1L;
    
    public static final String TYPE_TIME_MILLIS = "TIME_MILLIS";
    public static final String TYPE_INTEGER = "INTEGER";
    public static final String TYPE_FLOAT = "FLOAT";
    public static final String TYPE_STRING = "STRING";
    
    @Id @Column(name="sport_level_id")
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    
    @JoinColumn(name="sport_specialization_id", referencedColumnName="sport_specialization_id")
    @ManyToOne
    private SportSpecializationEntity sport;
    
    @Column(name="gender", nullable=false, columnDefinition="DEFAULT 'MALE'")
    String gender = "MALE";
    
    @Column(name="result_type", columnDefinition="DEFAULT '"+TYPE_TIME_MILLIS+"'")
    private String resultType = TYPE_TIME_MILLIS;
    
    @Column(name="units")
    private String units;
    
    @Column(name="name")
    private String name;
    
    @Column(name="description")
    private String description;
    
    @Column(name="min_value")
    private String minValue;
    
    @Column(name="max_value")
    private String maxValue;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getResultType() {
        return resultType;
    }

    public void setResultType(String resultType) {
        this.resultType = resultType;
    }

    public SportSpecializationEntity getSport() {
        return sport;
    }

    public void setSport(SportSpecializationEntity sport) {
        this.sport = sport;
    }

    public String getUnits() {
        return units;
    }

    public void setUnits(String units) {
        this.units = units;
    }

    public String getMaxValue() {
        return maxValue;
    }

    public void setMaxValue(String maxValue) {
        this.maxValue = maxValue;
    }

    public String getMinValue() {
        return minValue;
    }

    public void setMinValue(String minValue) {
        this.minValue = minValue;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SportLevelEntity)) {
            return false;
        }
        SportLevelEntity other = (SportLevelEntity) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ru.mipt.sport.model.entity.SportLevel[ id=" + id + " ]";
    }
    
}
